/**
 * 分页工具
 */
package com.zhao.utils;

import java.io.Serializable;

public class PageUtils implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 当前页数
	 */
	private int pageNum = 1;
	
	/**
	 * 每页信息数
	 */
	private int rows = 10;
	
	/**
	 * 总数
	 */
	private int total;
	
	/**
	 * 总页数
	 */
	private int totalPages;
	
	public PageUtils(int total, int pageNum){
		this.total = total;
		int more = total%rows;
		//获取总页数
		this.totalPages = total/rows;
		if (more > 0) {
			this.totalPages++;
		}
		this.pageNum = pageNum;
		
	}
	
	public int getPageNum() {
		if (pageNum > totalPages) {
			pageNum = totalPages;
		}else if (pageNum <= 0) {
			pageNum = 1;
		}
		return pageNum;
	}
	
	public int getTotal() {
		return total;
	}
	
	public int getTotalPages() {
		return totalPages;
	}

	public int getRows() {
		return rows;
	}
}
